package com.example.mall.client.fallback;

import com.example.mall.client.ProductFeignClient;
import com.example.mall.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: xxxliu
 * @CreateTime: 2025-06-03
 * @Version: 1.0
 */
@Component
public class ProductFeignClientFactory implements FallbackFactory<ProductFeignClient> {

    @Override
    public ProductFeignClient create(Throwable throwable) {
        return new ProductFeignClient() {
            @Override
            public JSONResult getProductInfo(Long id) {
                return JSONResult.error("商品查询失败");
            }

            @Override
            public JSONResult getProductInfos(List<Long> productIds) {
                return JSONResult.error("商品查询失败");
            }
        };
    }
}
